home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 6 / ads / s-tasini < prev    next >
Text File  |  1996-02-12  |  8KB  |  178 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --         S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N        --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.6 $                             --
  10. --                                                                          --
  11. --      Copyright (C) 1991,1992,1993,1994,1995 Florida State University     --
  12. --                                                                          --
  13. -- GNARL is free software; you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNARL; see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNARL was developed by the GNARL team at Florida State University. It is --
  32. -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  33. -- State University (http://www.gnat.com).                                  --
  34. --                                                                          --
  35. ------------------------------------------------------------------------------
  36.  
  37. --  This package provides overall initialization of the tasking portion of the
  38. --  RTS. This package must be elaborated before any tasking features are used.
  39. --  It also contains initialization for Ada Task Control Block (ATCB) records.
  40.  
  41. with System.Parameters;
  42. with System.Task_Info;
  43.  
  44. package System.Tasking.Initialization is
  45.  
  46.    --  The following record holds the information used to initialize a task
  47.  
  48.    type ATCB_Init is record
  49.       Task_Entry_Point : Task_Procedure_Access;
  50.       Task_Arg         : System.Address;
  51.       Stack_Size       : System.Parameters.Size_Type;
  52.       Activator        : Task_ID;
  53.       Parent           : Task_ID;
  54.       Master_of_Task   : Master_ID;
  55.       Elaborated       : Access_Boolean;
  56.       Entry_Num        : Task_Entry_Index;
  57.       Base_Priority    : System.Any_Priority;
  58.       Current_Priority : System.Any_Priority;
  59.       Task_Info        : System.Task_Info.Task_Info_Type;
  60.    end record;
  61.  
  62.    -----------------------
  63.    -- List of all Tasks --
  64.    -----------------------
  65.  
  66.    All_Tasks_List : Task_ID;
  67.    All_Tasks_L : System.Task_Primitives.Lock;
  68.    --  All_Tasks_L should not be locked by a task that holds any other
  69.    --  locks; in other words, All_Tasks_L should be the outermost lock.
  70.    --  Currently, only ATCB locks are locked at the same time as All_Tasks_L.
  71.  
  72.    procedure Remove_From_All_Tasks_List
  73.       (Source : Task_ID; Result : out Boolean);
  74.    --  Remove an entry from the All_Tasks_List.
  75.  
  76.    ---------------------------------
  77.    -- Tasking-Specific Soft Links --
  78.    ---------------------------------
  79.  
  80.    --  These permit us to leave out certain portions of the tasking
  81.    --  runtime system if they are not used.  They are only used internally
  82.    --  by the tasking runtime system.
  83.    --  So far, the only example is support for Ada.Task_Attributes.
  84.  
  85.    type Proc_T is access procedure (T : Task_ID);
  86.  
  87.    procedure Finalize_Attributes (T : Task_ID);
  88.    procedure Initialize_Attributes (T : Task_ID);
  89.  
  90.    Finalize_Attributes_Link : Proc_T := Finalize_Attributes'Access;
  91.    --  should be called with abortion deferred and T.L write-locked
  92.  
  93.    Initialize_Attributes_Link : Proc_T := Initialize_Attributes'Access;
  94.    --  should be called with abortion deferred, but holding no locks
  95.  
  96.    -----------------------------
  97.    -- ATCB related operations --
  98.    -----------------------------
  99.  
  100.    procedure Initialize_ATCB
  101.      (T    : Task_ID;
  102.       Init : ATCB_Init);
  103.    --  Initialize fields of a TCB and link into global TCB structures
  104.  
  105.    function New_ATCB
  106.      (Init : ATCB_Init)
  107.       return Task_ID;
  108.    --  New_ATCB creates a new ATCB using Ada allocators and initializes
  109.    --  it.
  110.  
  111.    function Unsafe_New_ATCB
  112.      (Init : ATCB_Init)
  113.       return Task_ID;
  114.    --  Like New_ATCB, but without the initialization.
  115.  
  116.    procedure Free_ATCB (T : in out Task_ID);
  117.    --  Release storage of a previously allocated ATCB
  118.  
  119.    ----------------------------------------------
  120.    -- RTS routine to be used for pragma assert --
  121.    ----------------------------------------------
  122.  
  123.    function Runtime_Assert_Shutdown (Msg : in String) return boolean;
  124.    --  This function is used to shut down the runtime when there is
  125.    --  an assertion error to be raise through "pragma Assert"
  126.    --  Usage should be either
  127.    --    pragma Assert (Runtime_Assert_Shutdown ("..."));
  128.    --    --  uncoditional shutdown
  129.    --  or
  130.    --    pragma Assert
  131.    --      (ASSERT_CONDITION or else Runtime_Assert_Shutdown ("..."));
  132.    --    --  conditional shutdown. Shut down the runtime only when the
  133.    --    --  ASSERT_CONDITION fails.
  134.  
  135.    --------------------------
  136.    -- Master ID operations --
  137.    --------------------------
  138.  
  139.    procedure Init_Master (M : out Master_ID);
  140.    pragma Inline (Init_Master);
  141.  
  142.    function Increment_Master (M : Master_ID) return Master_ID;
  143.    pragma Inline (Increment_Master);
  144.  
  145.    function Decrement_Master (M : Master_ID) return Master_ID;
  146.    pragma Inline (Decrement_Master);
  147.  
  148.    -------------------------------
  149.    -- Abortion related routines --
  150.    -------------------------------
  151.  
  152.    procedure Abort_Handler (Context : System.Task_Primitives.Pre_Call_State);
  153.    --  Handler to be installed at initialization; it is invoked by a task
  154.    --  when it is the target of an Abort_Task low-level operation.
  155.  
  156.    procedure Change_Base_Priority (T : Task_ID);
  157.    --  Change the base priority of T.
  158.    --  Has to be called with T.Lock write locked.
  159.  
  160.    procedure Defer_Abortion;
  161.    --  Defer the affects of low-level abortion in the calling task until a
  162.    --  matching Undefer_Abortion call is executed.  Defer_Abortion can be
  163.    --  nested; abortion will be deferred until the calling task has
  164.    --  called Undefer_Abortion for each outstanding call to
  165.    --  Defer_Abortion.  Note that abortion must be deferred before
  166.    --  calling any low-level (GNULLI) services.
  167. --    pragma Inline (Defer_Abortion); --  To allow breakpoints to be set. ???
  168.  
  169.    procedure Undefer_Abortion;
  170.    --  Undo the effects of one call to Defer_Abortion.  When the calling
  171.    --  task has called Undefer_Abortion for each outstanding call to
  172.    --  Defer_Abortion, any pending low-level abortion will take effect,
  173.    --  and subsequent low-level abortions will have an immediate
  174.    --  asynchronous effect.
  175. --    pragma Inline (Undefer_Abortion); --  To allow breakpoints to be set.
  176.  
  177. end System.Tasking.Initialization;
  178.